package com.lry.jvm.rtda;

import com.lry.jvm.rtda.heap.JMethod;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class JThread {
    private int pc;
    private Stack stack;

    public JThread(){
        this.stack = new Stack(1024);
    }

    public JThread(int maxStack) {
        this.stack = new Stack(maxStack);
    }

    public void pushFrame(Frame frame){
        this.stack.push(frame);
    }

    public Frame popFrame(){
        return this.stack.pop();
    }

    public Frame peekFrame(){
        return this.stack.peek();
    }

    public Frame newFrame(JMethod method){
        return new Frame(this,method);
    }

    public boolean isStackEmpty() {
        return stack.isStackEmpty();
    }
}
